#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"
#import "MyFlutterViewFactory.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.
  NSObject<FlutterPluginRegistrar> *registara =  [self registrarForPlugin:@"plugins.flutter.io/custom_platform_view_plugin"];
    MyFlutterViewFactory *factory = [[MyFlutterViewFactory alloc] initWithFlutterBinaryMessenger:registara.messenger];
    [registara registerViewFactory:factory withId:@"plugins.flutter.io/custom_platform_view"];
  return [super application:application
didFinishLaunchingWithOptions:launchOptions];
}

//直接使用method channel通信
//- (BOOL)application:(UIApplication *)application
//    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//      // Override point for customization after application launch.
//      NSObject<FlutterPluginRegistrar> *registara =  [self registrarForPlugin:@"com.flutter.madp.interaction"];
//      FlutterMethodChannel *messageChanel = [FlutterMethodChannel methodChannelWithName:@"com.flutter.madp.interaction" binaryMessenger:registara.messenger];
//    [messageChanel setMethodCallHandler:^(FlutterMethodCall * _Nonnull call, FlutterResult  _Nonnull result) {
//        if ([call.method isEqualToString:@"callNative"]) {
//            NSDictionary *dic = call.arguments;
//            NSString *action = dic[@"action"];
//            //flutter传递给OC的数据
//            NSDictionary *dataDic = dic[@"data"];
//            NSLog(@"%@",dataDic);
//            if ([action isEqualToString:@"closeFlutter"]) {
//
//            } else if ([action isEqualToString:@"getAppConfig"]) {
//                NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"tab" ofType:@"json"];
//                NSData *jsonData = [NSData dataWithContentsOfFile:jsonPath];
//                NSDictionary *jsonInfo = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
//                result(@{@"code":@(0),@"data":jsonInfo});
//                return;
//            } else if ([action isEqualToString:@"getPageConfig"]) {
//                NSString *pageID = dataDic[@"pageID"];
//                NSArray *types = @[@"banner",@"commonMenu",@"noticeBar",@"blockImage",@"productCard",@"blockImageScroller",@"ProductDesc", @"login",@"promptLabel",@"calendar",@"angecy",@"asset",@"tabPageList"];
//                NSMutableArray *infos = [NSMutableArray new];
//                for (NSString *type in types) {
//                    [infos addObject:@{@"type":type}];
//                }
//
//                result(@{@"code":@(0),@"data":@{@"components":infos}});
//                return;
//            }
//            result(@{@"msg":@"类型不支持",@"code":@(1)});
//        }
//    }];
//      return [super application:application didFinishLaunchingWithOptions:launchOptions];
//}
@end
